package org.geekbang.projects.cs.search.lucene.util;

import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.FSDirectory;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.concurrent.ExecutorService;

/**
 * @description:
 * @author: Kaijun Chen
 * @date: 2023/3/16
 **/
public class SearchUtil {

    public static IndexSearcher getIndexSearcher(String parentPath, ExecutorService service) throws IOException {
        IndexReader reader = null;
        reader = DirectoryReader.open(FSDirectory.open(Paths.get(parentPath, new String[0])));
        return new IndexSearcher(reader, service);
    }

}
